package models;

import play.db.ebean.Model;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.List;

@Entity
public class Svor extends Model {

    @Id
    public Long id;
    public String svar;
    public boolean rett;
    public long spurningid;

    public Svor(String svar, boolean rett, long spurningid) {
        this.svar = svar;
        this.rett = rett;
        this.spurningid = spurningid;
    }

    public static Model.Finder<Long,Svor> find = new Model.Finder(Long.class, Svor.class);

    public static List<Svor> findSpurning(Long spurningid) {
        return find.fetch("Spurningar").where()
                .eq("spurningid", spurningid)
                .findList();
    }

    public static Svor create(String svar, boolean rett, Long spurningid) {
        Svor svor = new Svor(svar, rett, spurningid);
        svor.save();
        return svor;
    }
}